import multiprocessing
import os

from pathlib import Path

LOG_DIR = "log"

Path(LOG_DIR).mkdir(parents=True, exist_ok=True)

if int(os.environ.get("DOCKER_MODE", 0)) == 0:
    daemon = True

debug = True
capture_output = True

loglevel = "debug"

pidfile = Path(LOG_DIR).joinpath("gunicorn.pid").as_posix()
accesslog = Path(LOG_DIR).joinpath("access.log").as_posix()
errorlog = Path(LOG_DIR).joinpath("error.log").as_posix()

if int(os.environ.get("DOCKER_MODE", 0)) == 1:
    bind = "0.0.0.0:3000"
else:
    bind = "127.0.0.1:3000"

backlog = 2048
workers = multiprocessing.cpu_count()
worker_connections = 1000
worker_class = "uvicorn.workers.UvicornH11Worker"
proc_name = "{{ cookiecutter.project_name }}"
x_forwarded_for_header = "X-FORWARDED-FOR"
timeout = 120
